﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using SSN.DotNet;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SSN.DotNextExtensionsTests
{
    [TestClass]
    public class Utilities
    {
        [TestMethod]
        public void StringUtilities()
        {
            string s = "The cow jumped over the moon.";
            Assert.IsTrue(s.SmartSubstring(24, 10) == "moon.");
            Assert.IsTrue(s.SmartSubstring(75) == "");

            StringBuilder sb = new StringBuilder();
            int[] list = new int[] { 0, 1, 2, 3, 4, 5 };
            foreach (var i in list)
            {
                sb.AppendFormatWithFirst("{0}", ",{0}", i);
            }

            Assert.IsTrue(sb.ToString() == "0,1,2,3,4,5");
            Assert.IsTrue(list.ToDelimitedString("|") == "0|1|2|3|4|5");
        }
    }
}
